package qfpay

import (
    "fmt"
	//"github.com/astaxie/beego"
)

type RefundData struct {
	RefundInfo struct {
		No            string `json:"no"`
		OrderNo       string `json:"order_no"`
		OuterRefundNo string `json:"outer_refund_no"`
		RefundAmount  string `json:"refund_amount"`
		Status        string `json:"status"`
	} `json:"refund"`
}

type RefundsResponse struct {
	RspHeader  *RspHeader  `json:"meta,omitempty"`
	RefundData *RefundData `json:"data,omitempty"`
}

func  Refunds(orderNo string, refundAmount int)(rsp *RefundsResponse, err error){
	
	merchanNo := "WC5c05ee8d44b1b"
	appsecret := ""
	var reqParams map[string]interface{}
	reqParams = make(map[string]interface{})
	reqParams["order_no"] = orderNo
	reqParams["refund_amount"] = refundAmount
	//reqParams["outer_refund_no"] = orderId
	reqURL := "https://openapi-test.qfpay.com/trade/v1/refund"
	sdk := NewSDK(reqURL, merchanNo, appsecret)
	respMap, err := sdk.Execute(reqParams)
	fmt.Println("err", err)
	fmt.Println("respMap", respMap)
	return
}

